package com.soyea.vo;

import lombok.Getter;

@Getter
public enum ResultEnum {
	SUCCESS(1, "成功"),
	SYSTEM_ERROR(2, "系统出现异常,请稍后再试"),
	PARAM_ERROR(3, "参数不正确"),

	USER_NAME_EXIST(4, "该名字已被登记"),
	USER_PHONE_EXIST(5, "该手机号已被登记"),
	PRIZE_STATUS_IS_NULL(6, "未选择抽奖等级"),
	USER_ALL_HAVE_PRIZE(7, "所有用户都已中奖,无法继续进行抽奖"),
	USER_AUTH_FAIL(8, "用户授权失败,请重新打开该页面进行授权"),
	GET_USER_INFO_FAIL(9, "获取用户信息失败,请重新打开该页面进行授权"),
	USER_OPENID_EXIST(10, "该微信号已被登记"),
	USER_PHONE_ERROR(11, "请输入合法的手机号"),
	MENU_CREATE_ERROR(12, "菜单创建出错")
	;

	private Integer code;
	private String message;

	ResultEnum(Integer code, String message) {
		this.code = code;
		this.message = message;
	}
	
	public static ResultEnum stateOf(int index) {
		for (ResultEnum state : values()) {
			if (state.getCode() == index) {
				return state;
			}
		}
		return null;
	}
}